Closed ldminoc closed 8 years ago
In both cases it just means that node can't resolve typescript
for some reason. Usually if you have it installed globally it will "just work", which is why there is the new message in 0.5.2. You could try installing locally. Go to your project root and use npm install typescript
. Maybe there is some weird configuration that is preventing node from being able to resolve typescript globally. I've run into weird resolution issues in the past on Windows with older versions of node. Maybe try updating node and npm if the local install doesn't work.
Wow impressive response time!
Your suggestion of installing typescript locally works, but it does not feel like a very satisfying solution ;-).
I'm running node v0.12.6, npm 2.11.2 on a mac so have no idea what the issue is.
Thanks for the help.
It's possible I should change the messaging to "Please install using npm install typescript
" instead based on this. In any case, glad it's working for you.
Sorry, should have closed this earlier.
No worries :)
FYI, I changed the message in the latest release to no longer have the -g
flag.
Another approach that worked for me is to install typescript globally (npm install -g typescript) and then link to it from the local folder (npm link typescript).
Just for documentation purposes: The preferGlobal
flag was removed in TS 1.6.
@OldrichDlouhy linking through npm link typescript
works perfectly, thanks!
@jbrantly I found the link option that is suggested as a noce solution thats more elegant, when typescript is installed globally. maybe change the message again to reflect this?
@ArgTang sure, sounds good.
Resolved in #127
Published in v0.8.0
It does not seem resolved at all. I still get this issue.
Attempted to resolve the problem using the prescribed methods in the error message (npm install typescript
and npm link typescript
) neither of these got rid of the problem.
awesome-typescript-loader does not have this issue. Switching to the alternative.
same issue here. after install of any module via npm install I have to re-run npm link typescript
I'd be very interested to see your repo - do you have one you can share?
not sure how repo will helps. here are files:
package.json
{
"name": "catapult",
"version": "1.0.0",
"description": "",
"dependencies": {
"antd": "^2.11.2",
"babel-register": "^6.24.1",
"firebase": "^4.1.3",
"lodash": "^4.17.4",
"polyglot": "^0.5.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-redux": "^5.0.5",
"redux": "^3.7.1",
"redux-multi": "^0.1.12",
"redux-thunk": "^2.2.0",
"type-to-reducer": "^1.0.3"
},
"devDependencies": {
"@types/react": "^15.0.34",
"@types/react-dom": "^15.5.1",
"babel-loader": "^7.1.1",
"babel-plugin-import": "^1.2.1",
"babel-plugin-lodash": "^3.2.11",
"babel-plugin-minify-dead-code-elimination": "^0.1.7",
"babel-plugin-module-resolver": "^2.7.1",
"babel-preset-electron": "^1.4.15",
"cross-env": "^5.0.1",
"css-loader": "^0.28.4",
"electron": "1.6.11",
"env-cmd": "^5.1.0",
"extract-text-webpack-plugin": "^2.1.2",
"file-loader": "^0.11.2",
"less": "^2.7.2",
"less-loader": "^4.0.4",
"react-hot-loader": "^3.0.0-beta.7",
"ts-loader": "^2.2.2",
"uglify-es": "git://github.com/mishoo/UglifyJS2.git#harmony",
"uglifyjs-webpack-plugin": "^0.4.6",
"webpack": "^3.0.0",
"webpack-bundle-tracker": "^0.2.0",
"webpack-dev-server": "^2.5.0"
},
"scripts": {
"build:desktop": "env-cmd ./env/prod.json tsc -p ./src/desktop",
"build:web": "env-cmd ./env/prod.json webpack",
"start": "npm run build:desktop && npm run start:desktop",
"start:desktop": "env-cmd ./env/dev.json electron -r babel-register ./dist/desktop/main.js",
"start:web": "env-cmd ./env/dev.json webpack-dev-server"
},
"author": "",
"license": "ISC"
}
webpack.config.js
const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = {
entry: {
app: './src/web/index.tsx',
common: [
'react',
'react-dom',
'moment',
'lodash',
'react-redux',
'redux',
// 'polyglot',
],
ui: 'antd',
// "locale-ru": './src/web/i18n/ru.js',
// "locale-en": './src/web/i18n/en.js',
},
output: {
filename: './[name].js',
path: path.resolve(__dirname, 'dist/web'),
publicPath: '/'
},
devServer: {
hot: true,
contentBase: path.resolve(__dirname, 'dist/web'),
publicPath: '/',
port: 8001,
stats: { modules:false }
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
web: process.cwd() + '/src/web',
shared: process.cwd() + '/src/shared',
},
},
module: {
rules: [
{ test: /\.tsx?$/, use: 'ts-loader'},
{ test: /\.html?$/, use: { loader: 'file-loader', query: { name: '[name].[ext]'}}},
{ test: /\.less$/i, use: ExtractTextPlugin.extract([ 'css-loader', 'less-loader' ])},
]
},
plugins: [
new ExtractTextPlugin('app.css'),
new webpack.optimize.CommonsChunkPlugin({
names: ['common', 'ui'],
minChunks: Infinity,
}),
],
};
if (process.env.NODE_ENV === 'production') {
config.devtool = false;
config.plugins.push(new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}));
config.plugins.push(new webpack.optimize.OccurrenceOrderPlugin());
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
screw_ie8: true,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
},
output: {
comments: false,
},
}));
} else {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
}
module.exports = config;
and here is tsconfig.json:
{
"compilerOptions": {
"jsx": "react",
"outDir": "../../dist/web",
"paths": {
"web/*": ["../web/*"],
"shared/*": ["../shared/*"]
}
},
"extends": "../../tsconfig.base"
}
tsconfig.base.json
{
"compilerOptions": {
"target": "es6",
"module": "es6",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"allowJs": true,
"strictNullChecks": true,
"noImplicitAny": false,
"allowSyntheticDefaultImports": true,
"baseUrl": "src"
},
"exclude": [
"node_modules"
]
}
You don't seem to have TypeScript installed as a devDependency?
@johnnyreilly yep, it installed globally. As I wrote - after any npm install I have to link it again :(
Install it as a devDependency and you shouldn't have an issue. That's how I use it.
I'm not sure why it wouldn't pick up the global - this could be something to do with your path?
@johnnyreilly of course I can install everything as local, but I would prefer to use globals for common things like webpack, typescript and etc.
@johnnyreilly I don't know why, but as I said - after any npm install (e.g. added a new package), I'm getting this error and have to link typescript.
linking with npm is not a solution, i have typescript
and electron
globally installed by npm in /usr/lib/node_modules
and in the tsconfig.json
basedir
is set to it. Running tsc
works without complainig about paths. To use ts-loader
i need to symlink everything installed globally. :(
tsc --version
Version 2.9.2
I updated to 0.5.2 from 0.5.0 this morning but still seem to be having the same issue although the new error message is less useful for problem identification. After receiving the error message, I updated typescript to the latest nightly build using 'npm install -g typescript@next'.
Any insights would be appreciated.
Here's my webpack.config.js:
And here is the tsconfig.js:
With 0.5.0, the error message was: ERROR in ./server/server.ts