pwa: Error: Cannot find module 'chalk'
Hey guys (@jeffposnick and all) am getting this error on my Heroku App after CI/CD from GitLab to Heroku. Following is the gitlab-ci.yml script:
image: node:6
stages:
- ver
- init
- tests
- deploy
cache:
paths:
- node_modules/
ver:
stage: ver
script:
- node --version
- whoami
init:
stage: init
script:
- npm install -g chalk
- npm cache clean
- rm -rf node-modules
- npm install
run_tests:
# needed for testing selenium on docker with java
image: karthikiyengar/node-nightwatch:0.0.1
stage: tests
script:
- sudo npm install
- sudo npm test
deploy_staging:
stage: deploy
script:
- npm install -g chalk
- npm cache clean
- rm -rf node-modules
- npm install
- git remote add heroku https://heroku:$HEROKU_API_KEY@git.heroku.com/webapp-staging.git
- git push heroku master
- echo "Deployed to staging server"
environment: staging
only:
- master
deploy_production:
stage: deploy
script:
- npm install -g chalk
- npm cache clean
- rm -rf node-modules
- npm install
- git remote add heroku https://heroku:$HEROKU_API_KEY@git.heroku.com/webapp.git
- git push heroku master
- echo "Deployed to production server"
environment: production
when: manual
only:
- master
Help will be greatly appreciated. Thanks
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 17
ATTENTION!!!
still doesnt work. still returning “Cannot find module ‘chalk’”. I tried: -
npm install -g chalk
-npm --production=false install
-npm cache clean
-tryed to deletenode_modules
, returningOPERATION NOT PERMITTED,ISTAT
'\node_modules\.staging\acorn-...\CHANGELOG.md'
Still without success(((( HELP!!!I think the problem is
npm install
skipping devDependencies whenNODE_ENV=production
. I fixed it withnpm --production=false install
Also happens on a direct PWA template deployment to Heroku, no
local-npm
installed. I believe it is caused because Heroku runs app asPRODUCTION
env (and specifically prunes dev modules), andChalk
is listed underdevDependencies
.I have also faced the same problem. I just deleted my node_modules folder and did
npm install
. It worked for me. Hope it will work for you also.The reason is
build/build.js
uses chalk. It may be moved into main dependencies, or made optional inbuild.js
depending on NODE_ENV (just make sure you do this before forcedprocess.env.NODE_ENV = 'production'
)Hey @nwaughachukwuma
local-npm
is a project I use when travelling so nvm is cached locally and I’m not using mobile data. https://www.npmjs.com/package/local-npmIf you haven’t installed it, then that’s probably not the problem. It’s possible there is a proxy server in the way that is caching/proxying incorrectly. The simplest thing that could possibly work is to delete
node_modules
or use a different version of node/nvm.