npm run: command not found - node.js

When I try to run npm run dev or npm run build I get the following error:
npm run dev
> dev
> next
/usr/bin/bash: D:Tempdev-1656515078305.sh: command not found
This is my current package.json:
{
"private": true,
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"type-check": "tsc"
},
"dependencies": {
"bootstrap": "^5.1.3",
"marked": "^4.0.17",
"next": "latest",
"nodemailer": "^6.7.5",
"react": "^18.1.0",
"react-bootstrap": "^2.4.0",
"react-dom": "^18.1.0",
"react-icons": "^4.4.0"
},
"devDependencies": {
"#fullhuman/postcss-purgecss": "^4.1.3",
"#types/node": "^17.0.35",
"#types/react": "^18.0.9",
"#types/react-dom": "^18.0.4",
"#typescript-eslint/eslint-plugin": "^5.30.0",
"#typescript-eslint/parser": "^5.30.0",
"eslint": "^8.18.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.2.3",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"postcss-preset-env": "^7.6.0",
"sass": "^1.53.0",
"tailwindcss": "^3.0.24",
"typescript": "4.6"
}
}
I have absolutely no idea why this error occurs.
NodeJS and NPM are installed:
node -v
v16.14.2
npm -v
8.13.1

I've encountered this issue when calling one run-script from another. Using npm-run-all and run-s to launch commands fixed my issues in some scenarios. I suspect that npm is making some assumptions about the shell and path separator based on the 'platform' or not properly introspecting the running shell.

Related

Why aws app runner looks trying to build packages on node 12 even if node 14 is selected?

I'm trying to generate a build of our Next.js application that is on a Github repository. We used node 14.19.3 to build the application, and it runs fine on local development.
The package.json of main project is
{
"name": "example-name",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"#apollo/client": "^3.6.4",
"graphql": "^16.5.0",
"#our-private-package": "^1.0.7",
"framer-motion": "^2.9.4",
"i18next": "^21.8.0",
"js-cookie": "^2.2.1",
"next": "^12.1.6",
"next-cookies": "^2.0.3",
"ni18n": "^1.0.3",
"prop-types": "^15.7.2",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-ga": "^3.3.0",
"react-i18next": "^11.16.9",
"react-icons": "^4.3.1",
"react-modal": "^3.11.2",
"react-redux": "^7.2.1",
"react-slick": "^0.27.11",
"react-slider": "^2.0.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"sass": "^1.26.11",
"slick-carousel": "^1.8.1"
},
"devDependencies": {
"#ermeschultz/chai-arrays": "^2.3.0",
"chai": "^4.2.0",
"eslint": "^7.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.0.0",
"esm": "^3.2.25",
"file-loader": "^6.1.0",
"mocha": "^8.1.3",
"prettier": "^2.1.1",
"redux-devtools-extension": "^2.13.8",
"redux-logger": "^3.0.6",
"url-loader": "^4.1.0"
}
}
Our private package have this package.json file:
{
"name": "#our-private-package",
"version": "1.0.7",
...
"engines": {
"yarn": ">=1.22.0",
"npm": ">=6.14.16",
"node": ">=14"
},
"scripts": {
"prepare": "npm run build",
"start": "node ./build/index.js",
"dev": "ts-node ./src/index.ts",
"build": "tsc --module commonjs"
},
"dependencies": {
"canvas": "^2.9.1",
"canvas-5-polyfill": "^0.1.5"
},
"devDependencies": {
"#types/node": "^17.0.33",
"#types/react": "^17.0.39",
"#types/react-dom": "^17.0.3",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
},
"peerDependencies": {
"react": "^17.0.0",
"react-dom": "^17.0.0"
}
}
To create the service, I selected nodejs 14 platform and put these build commands in the app runner user interface:
export VARIABLE=value; npm install; npm run build
*The variable is an env variable necessary to import some private packages.
And this running commands in the app runner user interface:
npm start
The build logs show the message:
"[Build] \u001b[0m\u001b[91mError: The module '/app/node_modules/canvas/build/Release/canvas.node'\n",
"[Build] was compiled against a different Node.js version using\n",
"[Build] NODE_MODULE_VERSION 72. This version of Node.js requires\n",
"[Build] NODE_MODULE_VERSION 83. Please try re-compiling or re-installing\n",
I removed the private package and then project builds successfully on app runner. But I just can't reproduce the same problem on my local machine.
The error on message was reported previously on Stack Overflow, always relating to the use of another version of node than the current used one. It is always solved by reinstalling, rebuilding, and/or clearing the npm cache. But app runner creates the container from scratch.
The interface shows that we are using Node js 14 environment. But it seems running on the Node js 12 platform when running npm run build command. At least for the canvas module build.
It could be a package conflict case. But, why this shows the message like it was build in node 12? Why the same problem does not happens in my local development even if I'm using same node and npm present in App Runner?
It is not a definitive complete answer to the question, but run yarn install; yarn build instead npm make the same code runs on app runner.

webpack-cli Unable to load '#webpack-cli/serve' command webpack-cli TypeError: devServerFlags is not iterable windows

I am extreme newb and just realized what webpack was/is doing but I still can not get it to run in my lesson. Here is the error
> dev
> webpack serve --config ./bundler/webpack.dev.js
[webpack-cli] Unable to load '#webpack-cli/serve' command
[webpack-cli] TypeError: devServerFlags is not iterable
at C:\Users\Gamer\code\threejs-dc-1\node_modules\#webpack-cli\serve\lib\index.js:28:43
at WebpackCLI.makeCommand (C:\Users\Gamer\code\threejs-dc-1\node_modules\webpack-cli\lib\webpack-cli.js:104:31)
at ServeCommand.apply (C:\Users\Gamer\code\threejs-dc-1\node_modules\#webpack-cli\serve\lib\index.js:10:19)
at loadCommandByName (C:\Users\Gamer\code\threejs-dc-1\node_modules\webpack-cli\lib\webpack-cli.js:626:35)
at Command.<anonymous> (C:\Users\Gamer\code\threejs-dc-1\node_modules\webpack-cli\lib\webpack-cli.js:1091:23)
at Command.listener [as _actionHandler] (C:\Users\Gamer\code\threejs-dc-1\node_modules\webpack-cli\node_modules\commander\index.js:922:31)
at Command._parseCommand (C:\Users\Gamer\code\threejs-dc-1\node_modules\webpack-cli\node_modules\commander\index.js:1503:14)
at Command.parse (C:\Users\Gamer\code\threejs-dc-1\node_modules\webpack-cli\node_modules\commander\index.js:1292:10)
at Command.parseAsync (C:\Users\Gamer\code\threejs-dc-1\node_modules\webpack-cli\node_modules\commander\index.js:1318:10)
at WebpackCLI.run (C:\Users\Gamer\code\threejs-dc-1\node_modules\webpack-cli\lib\webpack-cli.js:1123:28)
and here is my package.json
{
"repository": "#",
"license": "UNLICENSED",
"scripts": {
"build": "webpack --config ./bundler/webpack.prod.js",
"dev": "webpack serve --config ./bundler/webpack.dev.js"
},
"dependencies": {
"#babel/core": "^7.13.1",
"#babel/preset-env": "^7.13.5",
"babel-loader": "^8.2.2",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^7.0.0",
"css-loader": "^5.1.0",
"dat.gui": "^0.7.7",
"file-loader": "^6.2.0",
"html-loader": "^2.1.1",
"html-webpack-plugin": "^5.2.0",
"mini-css-extract-plugin": "^1.3.9",
"portfinder-sync": "0.0.2",
"raw-loader": "^4.0.2",
"style-loader": "^2.0.0",
"three": "^0.126.0",
"webpack": "^5.24.2",
"webpack-cli": "^4.5.0",
"webpack-dev-server": "^4.9.0",
"webpack-merge": "^5.7.3"
}
}
I am running the following:
webpack: 5.72.0
webpack-cli: 4.9.2
webpack-dev-server 4.9.0
node v16.15.0
npm 8.5.5
on Windows 10.
I have uninstalled (fully) node v18 and npm and reinstalled. I've uninstalled webpack and reinstalled. I am at a loss. Any help is appreciated! I haven't even gotten started on my lesson but I am learning a lesson for sure!
Diza

npm start not working because of Webpack mismatch

I recently copied over a React frontend into the assets folder of my Phoenix backend and also added Webpack.
When I run npm start, I get this error, even when I remove node modules folder and package-lock.json file and run npm install, I get the error again when running npm start.
The react-scripts package provided by Create React App requires a dependency:
"webpack": "4.19.1"
Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:
/Users/danale/Projects/node_modules/webpack (version: 4.29.0)
The error sounds straightforward except that I did a npm ls webpack and I am using the version the error says I should be using:
└─┬ react-scripts#2.0.5
└── webpack#4.19.1
Please point me in the direction I should be looking.
Here is my package.json file:
{
"name": "myproject",
"version": "0.1.0",
"private": true,
"dependencies": {
"#material-ui/core": "^3.2.1",
"#material-ui/icons": "^3.0.1",
"apollo-boost": "^0.1.23",
"apollo-cache-inmemory": "^1.4.0",
"apollo-link-context": "^1.0.12",
"apollo-link-http": "^1.5.9",
"axios": "^0.18.0",
"classnames": "^2.2.6",
"eslint-config-airbnb": "^17.1.0",
"graphql": "^14.0.2",
"graphql-tag": "^2.10.0",
"jest-dom": "^2.1.0",
"moment": "^2.22.2",
"phoenix": "^1.3.4",
"prop-types": "^15.6.2",
"react": "^16.5.2",
"react-apollo": "^2.3.3",
"react-beautiful-dnd": "^9.0.2",
"react-dom": "^16.5.2",
"react-redux": "^5.0.7",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "2.0.5",
"react-testing-library": "^5.2.0",
"redux": "^4.0.1",
"redux-saga": "^0.16.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},

How to resolve gulp dependencies while creating a NPM package

I have a nodeJs application(demo) which using commander package to take command line argument and using gulp for
build
docs
test
coverage
This functionality is working fine but Now I need to move this application as a NPM Package.
Changes are done according to according NPM Package but when I install this as NPM package npm install ../demo/ from local location.
It asks for following gulp dependencies: -
Cannot find module gulp
Cannot find module gulp-load-plugins
Cannot find module del
Cannot find module gulp-plumber
Cannot find module gulp-eslint
Cannot find module babel-eslint
Cannot find module gulp-debug
Cannot find module gulp-sourcemaps
Cannot find module gulp-babel
Every time I go back to the npm package(which i created) directory and run the command which occurs as an error like npm install gulp --save-dev and npm install del --save-dev and so on.
I also defined these dependencies in package.json but it is still throwing errors.
Is there any way to resolve this issue.
package.json
{
"name": "demo",
"version": "0.0.1",
"description": "",
"main": "./dist/index.js",
"license": "SEE LICENSE IN LICENSE.md",
"keywords": [],
"scripts": {
"build": "gulp build",
"coverage": "gulp coverage",
"docs": "gulp docs",
"prepublish": "gulp build",
"test": "gulp test"
},
"dependencies": {
"autobind-decorator": "^1.3.3",
"babel-polyfill": "^6.6.1",
"commander": "^2.9.0",
"lodash": "^4.0.0",
"mustache": "^2.2.1",
"source-map-support": "^0.4.0",
"wrench": "^1.5.8",
"ms": "^0.7.1"
"babel-eslint": "^6.0.4",
"babel-plugin-lodash": "^2.2.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-nodejs-lts": "^1.2.2",
"chai": "^3.5.0",
"del": "^2.2.0",
"esdoc-es7-plugin": "^0.0.3",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-babel-istanbul": "^1.1.0",
"gulp-debug": "^2.1.2",
"gulp-esdoc": "^0.2.0",
"gulp-eslint": "^2.0.0",
"gulp-filter": "^4.0.0",
"gulp-inject-modules": "^0.1.1",
"gulp-load-plugins": "^1.2.2",
"gulp-mocha": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.0.0-alpha",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"btoa": "^1.1.2",
"superagent": "^2.1.0"
},
"engines": {
"node": ">=4.0.0"
}
}
I put all the things in dependencies. I tried that way but having same problem.
npm install ../demo/
npm WARN package.json demo_project#1.0.0 No description
npm WARN package.json demo_project#1.0.0 No repository field.
npm WARN package.json demo_project#1.0.0 No README data
> demo#0.0.1 prepublish /work/demo
> gulp build
[16:53:33] Local gulp not found in ~/work/demo
[16:53:33] Try running: npm install gulp
Although the documentation doesn't mention it, npm install folder only installs dependencies and not devDependencies. This may be a little bit confusing as running npm install inside the package folder installs both dependenciesand devDependencies.
So try to install gulpand all the rest as npm install --save gulp (not
--save-dev)
UPDATE: after adding package.json:
everything under devDependencies in your package.json should be under dependencies:
{
"name": "demo",
"version": "0.0.1",
"description": "",
"main": "./dist/index.js",
"license": "SEE LICENSE IN LICENSE.md",
"keywords": [],
"scripts": {
"build": "gulp build",
"coverage": "gulp coverage",
"docs": "gulp docs",
"prepublish": "gulp build",
"test": "gulp test"
},
"dependencies": {
"autobind-decorator": "^1.3.3",
"babel-polyfill": "^6.6.1",
"commander": "^2.9.0",
"lodash": "^4.0.0",
"mustache": "^2.2.1",
"source-map-support": "^0.4.0",
"wrench": "^1.5.8",
"ms": "^0.7.1",
"babel-eslint": "^6.0.4",
"babel-plugin-lodash": "^2.2.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-nodejs-lts": "^1.2.2",
"chai": "^3.5.0",
"del": "^2.2.0",
"esdoc-es7-plugin": "^0.0.3",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-babel-istanbul": "^1.1.0",
"gulp-debug": "^2.1.2",
"gulp-esdoc": "^0.2.0",
"gulp-eslint": "^2.0.0",
"gulp-filter": "^4.0.0",
"gulp-inject-modules": "^0.1.1",
"gulp-load-plugins": "^1.2.2",
"gulp-mocha": "^2.2.0",
"gulp-plumber": "^1.1.0",
"gulp-sourcemaps": "^2.0.0-alpha",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"btoa": "^1.1.2",
"superagent": "^2.1.0"
},
"engines": {
"node": ">=4.0.0"
}
}

Module build failed: ReferenceError: [BABEL] Unknown option: /Users/Will/.babelrc.presets

So I am totally baffled by this. My team is running on the same branch, same commit of code. I'm the only one having this issue. Here's the full stack trace:
Module build failed: ReferenceError: [BABEL] /Users/Will/Brandzooka/visibl-front_end/node_modules/eslint-loader/index.js!/Users/Will/Brandzooka/visibl-front_end/app/index.jsx: Unknown option: /Users/Will/.babelrc.presets
at Logger.error (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/logger.js:58:11)
at OptionManager.mergeOptions (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:29)
at OptionManager.addConfig (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/options/option-manager.js:107:10)
at OptionManager.findConfigs (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/options/option-manager.js:168:35)
at OptionManager.init (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:12)
at File.initOptions (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/index.js:147:75)
at new File (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/file/index.js:137:22)
at Pipeline.transform (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-core/lib/transformation/pipeline.js:164:16)
at transpile (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-loader/index.js:12:22)
at Object.module.exports (/Users/Will/Brandzooka/visibl-front_end/node_modules/babel-loader/index.js:69:12)
I've come across multiple answers that all relate to Babel 6 usage, which doesn't currently apply to me.
I've tried:
Uninstalling and reinstalling node and npm versions (via nvm)
Blowing away all the node modules, and reinstalling
npm cache clean
Blowing away repo, and re-cloning
For good measure, restarting my machine
Im running node v0.12.9 & npm v2.14.9
Here's my package.json
{
"version": "0.0.0",
"main": "app/index.js",
"private": true,
"scripts": {
"build": "CONFIG_ENV=dev Q_DEBUG=1 time ./node_modules/.bin/webpack --config conf/webpack.production.js",
"build:prod": "CONFIG_ENV=production time ./node_modules/.bin/webpack --config conf/webpack.production.js",
"build:stage": "CONFIG_ENV=stage time ./node_modules/.bin/webpack --config conf/webpack.production.js",
"deploy:codeship-getvisibl": "time firebase deploy --token $FIREBASETOKEN",
"deploy:codeship-stage": "time firebase deploy --token $FIREBASETOKEN --project firebase-visibl-stage",
"deploy:stage": "firebase use firebase-visibl-stage && firebase deploy",
"lint": "PATH=$PATH:/usr/local/bin time ./node_modules/eslint/bin/eslint.js --cache --format 'node_modules/eslint-friendly-formatter' --ext .js --ext .jsx --config .eslintrc app/",
"migrate": "babel-node --stage 1 migrate.js",
"start": "CONFIG_ENV=dev Q_DEBUG=1 ./node_modules/.bin/webpack-dev-server --config conf/webpack.config.js --hot --progress --inline --content-base ./build",
"start:prod": "CONFIG_ENV=production Q_DEBUG=1 ./node_modules/.bin/webpack-dev-server --config conf/webpack.config.js --hot --progress --inline --content-base ./build",
"debug": "CONFIG_ENV=dev Q_DEBUG=1 time ./node_modules/.bin/mocha debug --full-trace --colors --recursive app/mochaNodeSetup.js app",
"test": "CONFIG_ENV=dev Q_DEBUG=1 time ./node_modules/.bin/mocha --full-trace --colors --bail --recursive app/mochaNodeSetup.js app"
},
"dependencies": {
"#brandzooka/client": "*",
"#brandzooka/models": "*",
"autoprefixer-loader": "2.0.0",
"aws-sdk": "^2.3.7",
"babel-core": "5.8.38",
"babel-loader": "5.3.2",
"baconjs": "0.7.66",
"bluebird": "2.10.1",
"bootstrap-sass": "3.3.5",
"bootstrap-slider": "4.10.0",
"chai": "3.0.0",
"chai-immutable": "1.0.2",
"classnames": "2.1.2",
"clear-require": "^1.0.1",
"cls-bluebird": "^1.0.1",
"css-loader": "0.15.1",
"dom-scroll-into-view": "1.2.0",
"eslint": "1.4.3",
"eslint-friendly-formatter": "1.0.8",
"eslint-loader": "^1.0.0",
"eslint-plugin-mocha": "0.4.0",
"eslint-plugin-react": "3.4.1",
"exports-loader": "0.6.2",
"file-loader": "0.8.4",
"immutable": "3.7.4",
"immutable-form-validation": "1.0.4",
"imports-loader": "0.6.4",
"jquery": "2.1.4",
"jsdom": "2.0.0",
"json-loader": "0.5.2",
"lodash": "3.10.1",
"mocha": "2.2.5",
"moment": "2.10.3",
"node-libs-browser": "0.5.2",
"node-sass": "3.2.0",
"nomnom": "^1.8.1",
"null-loader": "0.1.1",
"phantomjs": "1.9.18",
"precommit-hook": "2.0.1",
"q": "1.4.1",
"query-string": "3.0.3",
"rc-form-validation": "2.4.12",
"react": "^0.14.0",
"react-addons-pure-render-mixin": "0.14.0",
"react-addons-test-utils": "0.14.0",
"react-bootstrap": "0.29.5",
"react-bootstrap-daterangepicker": "0.2.5",
"react-dom": "0.14.0",
"react-dropzone": "1.2.2",
"react-hot-loader": "1.2.7",
"react-moment-proptypes": "0.0.5",
"react-router": "0.13.5",
"react-slick": "0.12.2",
"readline2": "^1.0.1",
"reflux": "0.4.1",
"reflux-core": "0.3.0",
"reflux-promise": "1.0.4",
"sass-loader": "1.0.2",
"sha.js": "2.4.5",
"sinon": "1.15.4",
"sinon-chai": "2.8.0",
"sinon-react": "0.2.1",
"style-loader": "0.12.3",
"superagent": "1.2.0",
"superagent-promise": "1.0.0",
"url": "0.10.3",
"url-loader": "0.5.6",
"uuid": "2.0.2",
"valid-url": "1.0.9",
"whatwg-fetch": "0.9.0"
},
"devDependencies": {
"babel": "5.8.38",
"babel-eslint": "^6.0.0-beta.6",
"chai-spies": "^0.7.1",
"clean-webpack-plugin": "0.1.3",
"estraverse": "^4.2.0",
"extract-text-webpack-plugin": "0.8.2",
"firebase-token-generator": "^2.0.0",
"html-webpack-plugin": "1.5.2",
"pg": "^4.4.2",
"pg-parse-float": "0.0.1",
"webpack": "*",
"webpack-dev-server": "*"
}
}
Any hot ideas out there? 3 hours in, I can't even get the error message to change.
The config path /Users/Will/.babelrc.presets means you have a .babelrc file in /Users/Will/, and it has a "presets" key because it appears to be a config file for Babel 6.
Presumably you have a .babelrc at /Users/Will/Brandzooka/visibl-front_end/.babelrc to configure your Babel 5 install, but Babel 5 does not stop traversing upward looking for other configs unless you tell it to (Babel 6 stops at the first config), so it will also look farther up and error out on the Babel 6 config in your home directory.
This leaves you with a few options:
Delete /Users/Will/.babelrc, because Babel config files should live in the project they apply to, not in your home.
If that is a no-go, open (and maybe create) /Users/Will/Brandzooka/visibl-front_end/.babelrc and make sure it has the key "breakConfig": true to tell Babel 5 to stop looking in parent directories for other config files.

Resources